<template>
<div class="index">
  <el-container class="h-h">
    <el-aside width="200px">
      <el-menu
        text-color="#bfcbd9"
        style="min-height: 100%;"
        theme="dark"
        @select="goPage"
        :defaultActive=menu.ac
        :defaultOpeneds=menu.open
      >
        <!--<el-menu-item index="info">-->
          <!--<i class="el-icon-menu"></i>-->
          <!--<span slot="title">首页</span>-->
        <!--</el-menu-item>-->
        <el-submenu index="1">
          <template slot="title"><i class="el-icon-plus"></i>添加数据</template>
          <el-menu-item index="add">添加问答</el-menu-item>
          <!--<el-menu-item index="info" disabled>添加其他</el-menu-item>-->
        </el-submenu>
        <el-submenu index="2">
          <template slot="title"><i class="el-icon-edit"></i>编辑</template>
          <el-menu-item index="edit">数据管理</el-menu-item>
          <!--<el-menu-item index="amend" disabled>应答编辑</el-menu-item>-->
        </el-submenu>
        <el-submenu index="3">
          <template slot="title"><i class="el-icon-setting"></i>设置</template>
          <el-menu-item index="adminSet" disabled>管理员设置</el-menu-item>
          <!-- <el-menu-item index="sendMessage">发送通知</el-menu-item> -->
        </el-submenu>
        <el-submenu index="4">
          <template slot="title"><i class="el-icon-warning"></i>帮助</template>
          <el-menu-item index="explain" disabled>使用说明</el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>
    <el-container  class="s-box">
      <el-header>
        <el-breadcrumb separator="/">
          <el-tooltip class="item" effect="light" content="快捷键 Alt + < (方向键)" placement="bottom">
            <el-breadcrumb-item @click.native="goBack">
              <i class="el-icon-arrow-left"></i>
              返回上一页&nbsp;&nbsp;&nbsp;&nbsp;
            </el-breadcrumb-item>
          </el-tooltip>
          <!--<el-breadcrumb-item :to="{ path: '/info' }">首页</el-breadcrumb-item>-->
          <el-breadcrumb-item v-for="(item, i) in $route.meta.navigation" :key="i">{{item}}</el-breadcrumb-item>
        </el-breadcrumb>
        <el-dropdown @command="handleCommand" menu-align='start'>
          <img src="../assets/2.jpg" class="avator">
          <el-dropdown-menu slot="dropdown">
            <!--<el-dropdown-item command="info">首页</el-dropdown-item>-->
            <el-dropdown-item command="singout">退出</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-header>
      <el-main>
        <!--<keep-alive>
          <router-view v-if="$route.meta.keepAlive"></router-view>
        </keep-alive>
        <router-view v-if="!$route.meta.keepAlive"></router-view>-->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</div>
</template>
<script>
export default {
  name: 'index',
  data: function () {
    return {
      menu: {
        ac: 'info',
        open: ['1', '2']
      }
    }
  },
  created: function () {}, // 创建时
  beforeMount: function () {}, // 挂载之前
  mounted: function () {}, // 挂载之后
  beforeUpdate: function () {
    this.menu.ac = this.defaultActive()
  }, // 数据更新时调用,在渲染之前
  updated: function () {}, // 数据更新后,渲染后调用(禁止)
  beforeDestroy: function () {}, // 实例销毁前调用,解绑中间层的数据传输
  destroyed: function () {}, // 实例销毁后调用
  methods: {
    goBack () {
      this.$router.back()
    },
    defaultActive () {
      return this.$route.path.replace('/', '')
    },
    goPage (i, t) {
      this.$router.push('/' + i)
    },
    handleCommand (command) {
      if (command === 'info') {
        this.$router.push('info')
      } else if (command === 'singout') {
        this.$message({
          type: 'success',
          message: '退出成功'
        })
        this.$router.push('/')
      }
    }
  } // 函数
}
</script>
<style lang='scss'>
html, body {
  font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

.avator {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}
.s-box{
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: red;
}
.index {
  height: 100%;
  box-sizing: border-box;
  min-width: 1200px;
  .h-h{
    height: 100%;
    box-sizing: border-box;
  }
}

.el-menu {
  background-color: #324057;
  text-align: left;
  .el-menu-item:focus, .el-menu-item:hover, .el-submenu__title:hover {
    background-color: #48576a;
  }
  .el-submenu__title i {
    color: #bfcbd9;
    font-size: 16px;
  }
  i {
    font-weight: bold;
    font-size: 16px;
  }
}

.el-header, .el-footer {
  background-color: #eff2f7;
  color: #333;
  text-align: center;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.el-aside {
  background-color: rgb(50, 64, 87);
  color: #333;
  text-align: center;
}
.el-main {
  height: calc(100% - 60px);
  overflow-y: scroll;
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
}
</style>
